﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using GameFramework.ModelManager;
using Microsoft.Xna.Framework.Graphics;
using GameFramework.Materials;

namespace MyRaceGame.GameLogic
{
    public abstract class RacerDecorator : RacerCharacter
    {
        public RacerDecorator(RacerCharacter racerCharacter)
        {
            this.racerCharacter = racerCharacter;
        }

        protected virtual void ExtraDrawing(Matrix view, Matrix projection, Vector3 cameraposition)
        {
        }

        protected virtual void ExtraUpdate(GameTime gameTime)
        {
        }

        public override void Draw(Matrix view, Matrix projection, Vector3 cameraposition)
        {
            racerCharacter.Draw(view, projection, cameraposition);

            if (enabled)
                ExtraDrawing(view, projection, cameraposition);
        }

        public override void Update(GameTime gameTime)
        {
            racerCharacter.Update(gameTime);

            if (enabled)
                ExtraUpdate(gameTime);
        }

        public override int CompareTo(object obj)
        {
            return racerCharacter.CompareTo(obj);
        }

        public override bool Equals(object obj)
        {
            return racerCharacter.Equals(obj);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        #region Overriden Properties

        public override RaceTrack RaceTrack
        {
            get { return racerCharacter.RaceTrack; }
            set { racerCharacter.RaceTrack = value; }
        }

        public override float TotalTrackLength
        {
            get { return racerCharacter.TotalTrackLength; }
            set { racerCharacter.TotalTrackLength = value; }
        }

        public override float InitialRotation
        {
            get { return racerCharacter.InitialRotation; }
            set { racerCharacter.InitialRotation = value; }
        }

        public override float Distance
        {
            get { return racerCharacter.Distance; }
            set { racerCharacter.Distance = value; }
        }

        public override float Speed
        {
            get { return racerCharacter.Speed; }
            set { racerCharacter.Speed = value; }
        }
        
        public override string Name
        {
            get { return racerCharacter.Name; }
            set { racerCharacter.Name = value; }
        }

        public override bool IsHuman
        {
            get { return racerCharacter.IsHuman; }
            set { racerCharacter.IsHuman = value; }
        }

        public override float PlaySpeed
        {
            get { return racerCharacter.PlaySpeed; }
            set { racerCharacter.PlaySpeed = value; }
        }

        public override IAnimationPlayer AnimationPlayer
        {
            get { return racerCharacter.AnimationPlayer; }
            set { racerCharacter.AnimationPlayer = value; }
        }

        public override Vector3 Scale
        {
            get { return racerCharacter.Scale; }
            set { racerCharacter.Scale = value; }
        }

        public override Vector3 Rotation
        {
            get { return racerCharacter.Rotation; }
            set { racerCharacter.Rotation = value; }
        }

        public override Vector3 Position
        {
            get { return racerCharacter.Position; }
            set { racerCharacter.Position = value; }
        }

        public override Model Model
        {
            get { return racerCharacter.Model; }
            set { racerCharacter.Model = value; }
        }

        public override Vector3 Forward
        {
            get { return racerCharacter.Forward; }
        }

        public override Vector3 Up
        {
            get { return racerCharacter.Up; }
        }

        public override Vector3 Velocity
        {
            get { return racerCharacter.Velocity; }
        }

        #endregion

        public bool Enabled
        {
            get { return enabled; }
            set { enabled = value; }
        }

        public RacerCharacter DecoratedRacerCharacter
        {
            get { return racerCharacter; }
            set { racerCharacter = value; }
        }

        protected bool enabled = true;
        protected RacerCharacter racerCharacter;
    }
}
